<template>
    <!-- 企业主营业绩 -->
    <div class="e-table table">
        <div class="top">
            <div class="left">
                <div>
                    <el-button
                        size="small"
                        type="primary"
                        plain
                        @click="aptitudeAddRow"
                        >添加</el-button
                    >
                    <el-button
                        size="small"
                        type="primary"
                        plain
                        @click="handleBatchDownload"
                        v-if="isBatch"
                        >批量下载</el-button
                    >
                    <el-button
                        size="small"
                        type="primary"
                        plain
                        @click="handleBatchDelete"
                        v-if="isBatch"
                        >批量删除</el-button
                    >
                </div>
                <div class="batchBox" @click="batchOperation">
                    <img class="batchicon" src="@/assets/piliang.png" />
                    <span class="batchfont">{{ batch }}</span>
                </div>
                <div style="margin-left: 10px">
                    系统内在建项目履行中的分包合同签订个数：<span
                        >{{ this.withinLength }}个</span
                    >
                    <el-popover
                        placement="top-start"
                        style="margin-left: 15px"
                        width="250"
                        trigger="hover"
                    >
                        <span class="tipck"
                            >1、分包合同录入机构的项目状态是在建</span
                        >
                        <span class="tipck">
                            2、分包合同状态是申请中、已申请待签订、已签订、变更申请中、已变更待签订、已变更签订中
                        </span>
                        <i
                            slot="reference"
                            class="el-icon-warning-outline greenFont"
                        ></i>
                    </el-popover>
                </div>
            </div>
            <div class="right" v-if="!isTableRowClass">
                <div class="squarecolor">
                    <div class="color colorAdd"></div>
                    <span>新增</span>
                </div>
                <div class="squarecolor item">
                    <div class="color colorUpdate"></div>
                    <span>修改</span>
                </div>
                <div class="squarecolor" style="margin-right: 10px">
                    <div class="color colorDel"></div>
                    <span>删除/过期</span>
                </div>
                <div class="right-div1">
                    <el-input
                        placeholder="请输入查询的内容"
                        v-model="keyword"
                        size="small"
                    >
                        <i slot="suffix" class="el-icon-search like"></i>
                    </el-input>
                </div>
                <div>
                    <el-button
                        size="small"
                        style="background: #2e61d7; color: #fff"
                        @click="search"
                        >搜索</el-button
                    >
                </div>
            </div>
        </div>
        <div
            style="margin-bottom: 20px"
            class="errorMsg"
            v-if="errorMsg.length > 0"
        >
            <span
                style="display: block"
                v-for="(item, index) in errorMsg"
                :key="index"
            >
                {{ item }}
            </span>
        </div>
        <el-table
            :data="aptitudeTable"
            border
            style="width: 100%"
            :max-height="$store.state.tableHeight"
            @selection-change="handleDetailSelectionChange"
            @cell-click="cellClick"
            :row-class-name="tableRowClass"
            ref="table"
            class="table"
            v-sortTable="{ 'tableData': aptitudeTable, '_this': this, 'ref': 'table' }"
        >
            <el-table-column
                type="selection"
                width="55"
                v-if="isBatch"
            ></el-table-column>
            <el-table-column label="序号" type="index" width="60">
            </el-table-column>
            <el-table-column fixed label="操作" width="120">
                <template slot-scope="{ row, $index }">
                    <div class="handle">
                        <el-upload
                            style="margin: 7px 5px 0px 0px"
                            class="upload-demo"
                            :action="uploadUrl"
                            :data="{
                                bucketName,
                                relationId,
                                orgCode
                            }"
                            :before-upload="beforeAvatarUpload"
                            :accept="accept"
                            :on-success="attachOnSuccess"
                            :http-request="uploadBefore"
                            :show-file-list="false"
                            name="files"
                        >
                            <img src="@/assets/btn/commit.png" />
                        </el-upload>
                        <img
                            v-if="row.id"
                            src="@/assets/btn/downLoad.png"
                            @click="handleDownload(row)"
                             style="margin-right: 5px"
                        />
                        <img
                            v-if="row.changeType != -1"
                            src="@/assets/btn/delete.png"
                            @click="handleDelete(row, $index)"
                        />
                        <img
                            v-else
                            src="@/assets/btn/cancelDelete.png"
                            @click="revoke($index)"
                        />
                        <img
                            style="margin-left: 10px"
                            src="@/assets/btn/preview.png"
                            @click="preview($index)"
                        />
                    </div>
                </template>
            </el-table-column>
            <el-table-column
                prop="contractName"
                label="合同名称"
                min-width="180"
                show-overflow-tooltip
            >
                <template slot-scope="{ row }">
                    <el-input
                        @change="modifyState(row)"
                        v-model.trim="row.contractName"
                        :readonly="row.source == 0"
                    ></el-input>
                </template>
            </el-table-column>
            <el-table-column
                prop="projectName"
                label="项目名称"
                min-width="180"
                show-overflow-tooltip
            >
                <template slot-scope="{ row }">
                    <el-input
                        @change="modifyState(row)"
                        v-model.trim="row.projectName"
                        :readonly="row.source == 0"
                    ></el-input>
                </template>
            </el-table-column>
            <el-table-column prop="contractAmount" label="合同金额（元）" width="160">
                <template slot-scope="{ row }">
                    <el-input
                        @change="modifyState(row)"
                        v-model.trim="row.contractAmount"
                        v-enterJustFloat
                        type="number"
                        style="margin-right:10px"
                        :readonly="row.source == 0"
                        @change.native="isFourInput"
                    ></el-input>
                </template>
            </el-table-column>
            <el-table-column
                prop="workContect"
                label="所承担工程内容"
                min-width="180"
                show-overflow-tooltip
            >
                <template slot-scope="{ row }">
                    <el-input
                        @change="modifyState(row)"
                        v-model.trim="row.workContect"
                        :readonly="row.source == 0"
                    ></el-input>
                </template>
            </el-table-column>
            <el-table-column prop="startDate" label="开工时间" width="150">
                <template slot-scope="{ row }">
                    <el-date-picker
                        type="date"
                        placeholder="选择日期"
                        value-format="yyyy-MM-dd"
                        v-model="row.startDate"
                        style="width: 100%"
                        :readonly="row.source == 0"
                        @change="modifyState(row)"
                    ></el-date-picker>
                </template>
            </el-table-column>
            <el-table-column prop="endDate" label="竣工时间" width="150">
                <template slot-scope="{ row }">
                    <el-date-picker
                        type="date"
                        placeholder="选择日期"
                        value-format="yyyy-MM-dd"
                        v-model="row.endDate"
                        style="width: 100%"
                        :readonly="row.source == 0"
                        @change="modifyState(row)"
                    ></el-date-picker>
                </template>
            </el-table-column>
            <el-table-column
                prop="projectLeader"
                label="项目负责人"
                width="120"
            >
                <template slot-scope="{ row }">
                    <el-input
                        @change="modifyState(row)"
                        v-model.trim="row.projectLeader"
                        :readonly="row.source == 0"
                    ></el-input>
                </template>
                <!-- <template slot-scope="{ row }">
                    <el-input v-model="row.projectLeader" autocomplete="off"></el-input>
                </template> -->
            </el-table-column>
            <el-table-column prop="witnessName" label="业绩证明人" width="120">
                <template slot-scope="{ row }">
                    <el-input
                        @change="modifyState(row)"
                        v-model.trim="row.witnessName"
                        :readonly="row.source == 0"
                    ></el-input>
                </template>
                <!-- <template slot-scope="{ row }">
                    <el-input v-model="row.witnessName" autocomplete="off"></el-input>
                </template> -->
            </el-table-column>
            <el-table-column
                prop="witnessTel"
                label="证明人电话"
                min-width="140"
                v-enterNumber
                show-overflow-tooltip
            >
                <template slot-scope="{ row }">
                    <el-input
                        @change="modifyState(row)"
                        v-model.trim="row.witnessTel"
                        :readonly="row.source == 0"
                    ></el-input>
                </template>
                <!-- <template slot-scope="{ row }">
                    <el-input v-model="row.witnessTel" autocomplete="off"></el-input>
                </template> -->
            </el-table-column>
            <el-table-column
                prop="opinion"
                label="质量安全信誉评价意见"
                min-width="180"
                show-overflow-tooltip
            >
                <template slot-scope="{ row }">
                    <el-input
                        @change="modifyState(row)"
                        v-model.trim="row.opinion"
                        :readonly="row.source == 0"
                    ></el-input>
                </template>
                <!-- <template slot-scope="{ row }">
                    <el-input v-model="row.opinion" autocomplete="off"></el-input>
                </template> -->
            </el-table-column>
            <el-table-column
                prop="fileName;"
                label="业绩附件"
                min-width="200"
                show-overflow-tooltip
            >
                <template slot-scope="{ row }">
                    {{ row.fileName }}
                </template>
            </el-table-column>
            <el-table-column
                label="合同类型"
                min-width="150"
                show-overflow-tooltip
            >
                <template slot-scope="{ row }">
                    {{
                        row.source == '1'
                            ? '--'
                            : options.subTypeForm[row.contractType]
                    }}
                </template>
            </el-table-column>
            <el-table-column prop="contractState" label="合同状态" width="120">
                <template slot-scope="{ row }">
                    {{
                        row.source == '1'
                            ? '--'
                            : options.stateArr[row.contractState]
                    }}
                </template>
            </el-table-column>
            <el-table-column prop="source" label="业绩来源" width="120">
                <template slot-scope="{ row }">
                    {{ ['系统内', '系统外'][row.source] }}
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import '@/utils/jquery.scrollTo.min'
import ossRequest from '@/api/oss/oss.js'
import { performanceList } from '@/api/OutsourcingartyAdmin/subcontractorAdmin/subcontractor.js'
import subcontractorChange from '@/api/OutsourcingartyAdmin/subcontractorAdmin/subcontractorChange.js'
import { bytesToSize, showLoading, hideLoading, getUuid, showPromptPop } from '@/utils/common'
import { isFourInput } from '@/utils/rules'
import { mapState } from 'vuex'
import service from '@/utils/request'
//import ComPagination from '@/components/pagination/pagination'
export default {
    props: {
        bucketName: {
            type: String,
            default: '',
            require: true
        },
        billId: {
            type: String,
            default: '',
            require: true
        },
        outerNames: {
            type: String,
            default: '',
            require: true
        },
        firmPerformanceTables: {
            type: Array,
            require: true
        },
        fun: {
            type: Function,
            default: null
        },
        // isView: {
        //     type: Boolean,
        //     default: false
        // }
        // 是否需要修改样式
        isTableRowClass: {
            type: Boolean,
            default: false
        },
        // 是否通过验证
        firmPerformanceSend: {
            type: Boolean,
            default: false
        }
    },
    data () {
        return {
            isBatch: false, //是否进入批量操作
            batch: '进入批量管理',
            aptitudeTable: [], //表格数据
            checkedDetail: [], //选中的数据
            //上传的地址
            uploadUrl: '/oss/uploader',
            accept: '.jpg,jpeg,.png,.pdf',
            relationId: '',
            pagination: {
                limit: 10, //	每页显示条数
                name: '', //合同名称
                orgName: '', //机构
                page: 1 //当前页数
            },
            totalPage: 0, //总页数
            rowIndex: '',
            certType: [],
            keyword: '', //搜索的字段
            errorMsg: [], //验证数组
            withinLength: 0, //系统内数据条数
            oldDate: [], //列表查回来的基础数据
        }
    },
    created () {
        // 列表数据
        this.performanceList(this.billId)
    },
    mounted () {},
    computed: {
        ...mapState({
            options: state => state.contract.ctClassify
        }),
        orgCode () {
            return this.$store.state.userInfo.orgInfo.shortCode
        }
    },
    methods: {
        //搜索
        search () {
            this.$emit('search', this.keyword)
            this.fun()
        },
        //修改行样式
        tableRowClass ({ row }) {
            if (this.isTableRowClass) {
                return
            } else {
                if (row.state == -1) {
                    return 'red'
                } else if (row.state == 1) {
                    return 'green'
                } else if (row.state == 2) {
                    return 'yellow'
                }
                return ''
            }
        },
        //是否批量管理
        batchOperation () {
            this.isBatch = !this.isBatch
            if (this.isBatch) {
                this.batch = '退出批量管理'
                this.$refs.table.clearSelection()
            } else {
                this.batch = '进入批量管理'
            }
        },
        cellClick (row) {
            //是第几行
            this.rowIndex = this.aptitudeTable.findIndex(x => x === row)
        },
        //添加一行
        aptitudeAddRow () {
            let obj = {
                changeType: 1,
                contractAmount: '',
                contractName: '',
                contractState: '',
                contractStateDesc: '',
                contractType: '',
                contractTypeDesc: '',
                effectiveness: '',
                endDate: '',
                filePath: '',
                gmtCreate: '',
                gmtModified: '',
                id: '',
                opinion: '',
                outerBillId: this.billId, //外包方id
                outerName: this.outerNames, //外包方名字,
                outerTypeKey: '',
                outerTypeValue: '',
                projectLeader: '',
                projectName: '',
                projectRemark: '',
                relationId: '',
                source: 1,
                sourceId: '',
                sourceName: '',
                startDate: '',
                state: 1,
                witnessName: '',
                witnessTel: '',
                workContect: '',
                uuid: getUuid(), //本地的uuid区分每条数据
                newState: '1', //当期新增字段，判断是当前次新增的数据还是从后端请求回来的数据
                dialogImage: '' //图片预览
            }
            this.aptitudeTable.push(obj)
        },
        //选中的行
        handleDetailSelectionChange (selection) {
            this.checkedDetail = selection
        },
        // 验证合同金额
        isFourInput (event) {
            isFourInput(event)
        },
        //删除一行
        handleDelete (row, $index) {
            if (row.source == 0) {
                showPromptPop('系统内数据不能删除')
            } else {
                //删除一行
                if (this.isTableRowClass) {
                    this.clientPop(
                        'info',
                        this.oneDeleteErr,
                        this.callback(row, $index)
                    )
                } else {
                    this.clientPop(
                        'info',
                        this.oneDeleteErr,
                        this.callbacks(row, $index)
                    )
                }
            }
        },
        // 编辑删除回调
        callback (row, index) {
            return () => {
                if(row.id) {
                    let data = []
                    row.changeType = -1
                    // 判断是否是原单数据，【只有变更数据才会有原单id】
                    if (row.sourceId) {
                        row.state = -1
                    }
                    data.push(row)
                    this.$emit('getFirmPerformanceData', data)
                }else{
                    this.aptitudeTable.splice(index, 1)
                }
            }
        },
        // 变更删除回调
        callbacks (row, index) {
            return () => {
                if (!row.newState) {
                    this.aptitudeTable[index].changeType = -1
                    this.aptitudeTable[index].state = -1
                } else {
                    this.aptitudeTable.splice(index, 1)
                }
            }
        },
        // 撤销
        revoke (index) {
            this.aptitudeTable[index].changeType = 0
            this.aptitudeTable[index].state = 1
        },
        //批量删除
        handleBatchDelete () {
            const length = this.checkedDetail.length
            this.clientPop(
                'info',
                `已选择【${length}】条数据，确定要删除吗？`,
                this.delete
            )
        },
        delete () {
            this.checkedDetail.filter(item => {
                // 如果有id ，则改changeType为-1
                if (item.id) {
                    item.changeType = -1
                } else {
                    // 如果没有id，判断uuid是否相同，相同则在原数据删除
                    this.aptitudeTable.map((items, index) => {
                        if (item.uuid == items.uuid) {
                            this.aptitudeTable.splice(index, 1)
                        }
                    })
                }
            })
            // 直接过滤所有无id的数据
            let data = this.checkedDetail.filter(item => {
                if (item.id) {
                    return item
                }
            })
            this.$emit('getFirmPerformanceData', data)
        },
        //下载某一行
        async handleDownload (obj) {
            showLoading()
            const url = obj.dialogImage
            const fileNameFull = obj.fileName
            const fileExt = fileNameFull.split('.').pop()
            if (
                ['jpg', 'jpeg', 'gif', 'png', 'bmp'].indexOf(
                    fileExt.toLowerCase()
                ) === -1
            ) {
                const { httpGetFile } = service
                const data = await httpGetFile({ url })
                const blob = new Blob([data])
                const reader = new FileReader()
                reader.readAsDataURL(blob)
                reader.onload = function (e) {
                    this.autoClick({
                        fileName: fileNameFull,
                        url: e.target.result
                    })
                }.bind(this)
            } else {
                this.downloadIamge(url, fileNameFull)
            }
            hideLoading()
        },
        downloadIamge (imgsrc, fileName) {
        //下载图片地址和图片名
            var image = new Image()
            // 解决跨域 Canvas 污染问题
            image.setAttribute('crossOrigin', 'anonymous')
            image.onload = function () {
                const canvas = document.createElement('canvas')
                canvas.width = image.width
                canvas.height = image.height
                const context = canvas.getContext('2d')
                context.drawImage(image, 0, 0, image.width, image.height)
                const _dataURL = canvas.toDataURL('image/png') //得到图片的base64编码数据

                const blob_ = this.dataURLtoBlob(_dataURL) // 用到Blob是因为图片文件过大时，在一部风浏览器上会下载失败，而Blob就不会

                const url = {
                    name: fileName || '图片.png', // 图片名称不需要加.png后缀名
                    src: blob_
                }

                if (window.navigator.msSaveOrOpenBlob) {
                // if browser is IE
                    navigator.msSaveBlob(url.src, url.name) //filename文件名包括扩展名，下载路径为浏览器默认路径
                } else {
                    this.autoClick({
                        fileName: url.name,
                        url: window.URL.createObjectURL(url.src)
                    })
                }
            }.bind(this)
            image.src = imgsrc
        },
        dataURLtoBlob (dataurl) {
            var arr = dataurl.split(','),
                mime = arr[0].match(/:(.*?);/)[1],
                bstr = window.atob(arr[1]),
                n = bstr.length,
                u8arr = new Uint8Array(n)
            while (n--) {
                u8arr[n] = bstr.charCodeAt(n)
            }
            return new Blob([u8arr], { type: mime })
        },
        autoClick ({ fileName, url }) {
            const elink = document.createElement('a')
            elink.download = fileName
            elink.style.display = 'none'
            elink.href = url
            document.body.appendChild(elink)
            elink.click()
            document.body.removeChild(elink)
        },
        //批量下载
        handleBatchDownload () {},
        //文件大小
        beforeAvatarUpload (file) {
            const isLt2M = file.size / 1024 / 1024 < 20

            if (!isLt2M) {
                this.clientPop('err', '上传文件大小不能超过 20MB！')
            }
            return isLt2M
        },
        //上传成功
        attachOnSuccess () {
            this.getObjectByRelationId()
        },
        //获取上传成功的对象
        getObjectByRelationId () {
            if (!this.relationId) return
            return ossRequest
                .getObjectByRelationId({ relationId: this.relationId })
                .then(res => {
                    res.map(x => {
                        x.fileName = x.objectName
                        return scrollX
                    })
                    this.$set(
                        this.aptitudeTable[this.rowIndex],
                        'dialogImage',
                        res[0].objectPath
                    )
                    this.$set(
                        this.aptitudeTable[this.rowIndex],
                        'fileName',
                        res[0].objectName
                    )
                    this.$set(
                        this.aptitudeTable[this.rowIndex],
                        'relationId',
                        this.relationId
                    )
                    this.modifyState(this.aptitudeTable[this.rowIndex])
                })
        },
        bytesToSize (byte) {
            return bytesToSize(byte)
        },
        //覆盖默认的上传行为，可以自定义上传的实现
        uploadBefore (params) {
            this.$Ajax
                .httpGet({
                    url: '/uid/builder?num=1',
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded'
                    }
                })
                .then(res => {
                    params.data.relationId = res[0]
                    this.relationId = res[0]
                    let obj = {
                        ...params.data,
                        files: params.file
                    }
                    this.$Ajax
                        .httpPostForm({
                            url: this.uploadUrl,
                            params: obj
                        })
                        .then(() => {
                            this.attachOnSuccess()
                        })
                })
                .catch(error => {
                    this.clientPop('err', error, this.handleClose)
                })
        },
        // 修改样式
        modifyState (row) {
            this.oldDate.map(item => {
                if (item.id == row.id && row.relationId) {
                    // if( !this.isObjectValueEqual(item, row)) {
                    this.aptitudeTable.map(items => {
                        if (items.id == row.id) {
                            return (items.state = 2)
                        }
                    })
                    // }
                }
            })
        },
        //保存
        preserve () {
            this.errorMsg = []
            let isStr = false
            // 首先将changeTy为-1的过滤掉
            let data =   this.aptitudeTable.filter(item=>{
                return item.changeType != -1
            })
            data.forEach((item, index) => {
                let str1 = `请完善第 ${index + 1} 行的`
                if (item.contractName === '' || item.contractName === null) {
                    let str = '合同名称,'
                    isStr = true
                    str1 += str
                }
                if (item.projectName === '' || item.projectName === null) {
                    let str = '项目名称,'
                    isStr = true
                    str1 += str
                }
                if (
                    item.contractAmount === '' ||
                    item.contractAmount === null
                ) {
                    let str = '合同金额,'
                    isStr = true
                    str1 += str
                }
                if (item.workContect === '' || item.workContect === null) {
                    let str = '所承担工程内容,'
                    isStr = true
                    str1 += str
                }
                if (item.startDate === '' || item.startDate === null) {
                    let str = '开工时间,'
                    isStr = true
                    str1 += str
                }
                if (item.endDate === '' || item.endDate === null) {
                    let str = '结束时间,'
                    isStr = true
                    str1 += str
                }
                if (item.projectLeader === '' || item.projectLeader === null) {
                    let str = '项目负责人,'
                    isStr = true
                    str1 += str
                }
                if (item.witnessName === '' || item.witnessName === null) {
                    let str = '业绩证明人,'
                    isStr = true
                    str1 += str
                }
                if (item.fileName === '' || item.fileName === null) {
                    let str = '业绩附件,'
                    isStr = true
                    str1 += str
                }
                if (item.witnessTel === '' || item.witnessTel === null) {
                    let str = '证明人电话,'
                    isStr = true
                    str1 += str
                }else{
                    if(!(/^1[3-9]\d{9}$/.test(item.witnessTel))) {
                        let str = '证明人电话格式不正确！'
                        isStr = true
                        str1 += str
                    }
                }
                if (Date.parse(item.startDate) >= Date.parse(item.endDate)) {
                    let str = '结束时间必须大于开始时间,'
                    isStr = true
                    str1 += str
                }
                if (item.id) {
                    return (item.changeType = 2)
                }
                if (isStr) {
                    this.errorMsg.push(str1)
                }
            })
            if (this.errorMsg.length > 0) {
                this.$emit('update:firmPerformanceSend', false)
                this.$emit('setError', 'firmPerformance')
                return
            } else {
                if (data.length > 0) {
                    data.map(item => {
                        // 判断变更已经删除的数据
                        if (item.state != -1) {
                            // 有数据就将数据返回,并将验证数据改为true
                            this.$emit('update:firmPerformanceSend', true)
                            this.$emit(
                                'update:firmPerformanceTables',
                                data
                            )
                        } else {
                            this.$emit('update:firmPerformanceSend', false)
                            this.$emit('setError', 'firmPerformance')
                            this.errorMsg.push('请至少添加一条企业主要业绩')
                        }
                    })
                } else {
                    this.$emit('update:firmPerformanceSend', false)
                    this.$emit('setError', 'firmPerformance')
                    this.errorMsg.push('请至少添加一条企业主要业绩')
                }
            }
        },
        // 列表
        async performanceList (val) {
            if (this.isTableRowClass) {
                let data = await performanceList({ billId: val, keyword: '' })
                this.aptitudeTable = data
                if (data.length > 0) {
                    /**
                 * a.项目状态是在建；
                    b.分包合同状态是申请中、已申请待签订、已签订、变更申请中、已变更待签订、已变更签订中。
                 */
                    data.map(item => {
                        if (
                            this.options.stateArr[item.contractState] ==
                                '申请中' ||
                            this.options.stateArr[item.contractState] ==
                                '已申请待签订' ||
                            this.options.stateArr[item.contractState] ==
                                '已签订' ||
                            this.options.stateArr[item.contractState] ==
                                '变更申请中' ||
                            this.options.stateArr[item.contractState] ==
                                '已变更待签订' ||
                            this.options.stateArr[item.contractState] ==
                                '已变更签订中'
                        ) {
                            this.withinLength += 1
                        }
                    })
                }
            } else {
                let data = await subcontractorChange.changeAchievementList({
                    billId: val,
                    keyword: ''
                })
                this.aptitudeTable = data
                this.oldDate = JSON.parse(JSON.stringify(this.aptitudeTable))
                if (data.length > 0) {
                    /**
                 * a.项目状态是在建；
                    b.分包合同状态是申请中、已申请待签订、已签订、变更申请中、已变更待签订、已变更签订中。
                 */
                    data.map(item => {
                        if (
                            this.options.stateArr[item.contractState] ==
                                '申请中' ||
                            this.options.stateArr[item.contractState] ==
                                '已申请待签订' ||
                            this.options.stateArr[item.contractState] ==
                                '已签订' ||
                            this.options.stateArr[item.contractState] ==
                                '变更申请中' ||
                            this.options.stateArr[item.contractState] ==
                                '已变更待签订' ||
                            this.options.stateArr[item.contractState] ==
                                '已变更签订中'
                        ) {
                            this.withinLength += 1
                        }
                    })
                }
            }
        },
        //预览附件
        preview (val) {
            if (this.aptitudeTable[val].dialogImage) {
                window.open(this.aptitudeTable[val].dialogImage)
            } else {
                this.clientPop('err', '请先上传附件')
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.like {
    color: rgb(46, 97, 215);
    font-size: 17px;
    line-height: 30px;
    cursor: pointer;
}
.handle {
    display: flex;
    align-items: center;
    text-align: left;
    div {
        cursor: pointer;
    }
    .download {
        font-size: 23px;
        font-weight: bold;
        color: rgb(122, 168, 24);
    }
}
</style>
